package com.hackintosh.scenery;

import java.util.List;

/**
 * @description：婺源景点迭代器
 * @author：twislyn
 * @date：Created in 2021/06/03
 * @modified By：
 * @version: 1.0
 */
public class WyViewSpotIterator implements ViewSpotIterator {
    private List<WyViewSpot> list;

    WyViewSpot cSharp = null;

    private int index = -1;

    public WyViewSpotIterator(List<WyViewSpot> list) {
        this.list = list;
    }

    @Override
    public boolean hasNext() {
        if (index < list.size() - 1) {
            return true;
        }
        return false;
    }

    @Override
    public WyViewSpot first() {
        index = 0;
        cSharp = list.get(index);
        return cSharp;
    }

    @Override
    public WyViewSpot next() {
        if (this.hasNext()) {
            cSharp = list.get(++index);
        }
        return cSharp;
    }

    @Override
    public WyViewSpot previous() {
        if (index > 0) {
            cSharp = list.get(--index);
        }
        return cSharp;
    }

    @Override
    public WyViewSpot last() {
        index = list.size() - 1;
        cSharp = list.get(index);
        return cSharp;
    }
}
